from django.utils.translation import gettext_lazy as _
from django.urls import reverse


article = {'url': reverse('article'), 'name': _('article'), 'children': []}
ftp = {'url': '/ftp/', 'name': _('ftp'), 'children': []}
message = {'url': '#', 'name': _('message board'), 'children': []}
contact = {'url': '#', 'name': _('contact'), 'children': []}
about = {'url': '#', 'name': _('about'), 'children': []}
admin_ftp = {'url': reverse('admin_ftp', kwargs={'path': ''}), 'name': _('admin ftp')}
logout = {'url': reverse('logout'), 'name': _('logout')}
admin_article = {'url': '', 'name': _('admin article')}
admin = {'url': '', 'name': _('admin'), 'children': [admin_ftp, logout, admin_article]}


MENU = [article, ftp, message, contact, about]

ADMIN_MENU = MENU + [admin]


def menu(request):
    args = request.GET
    if ('who' in args and args['who'] == 'admin') or request.user.is_authenticated:
        return {'MENU': ADMIN_MENU}
    return {'MENU': MENU}